home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / ext / IC / ICPPCGlue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-07  |  7.0 KB  |  329 lines  |  [TEXT/MPS ]

  1. #include <Types.h>
  2. #include <MixedMode.h>
  3. #include <GestaltEqu.h>
  4. #include <Components.h>
  5. #include <Errors.h>
  6.  
  7. #include "ICTypes.h"
  8. #include "ICCAPI.h"
  9.  
  10. #pragma options align=mac68k
  11.  
  12. enum {
  13.     uppCallComponentProcInfo = kPascalStackBased
  14.         | RESULT_SIZE(kFourByteCode)
  15.         | STACK_ROUTINE_PARAMETER(1, kFourByteCode)
  16. };
  17.  
  18.  
  19. pascal ICError ICStart(ICInstance *inst, OSType creator)
  20. {
  21.     ICError junk;
  22.     ICError err;
  23.     long response;
  24.     struct {
  25.         char flags;
  26.         char size;
  27.         short what;
  28.         //
  29.         OSType creator;
  30.         //
  31.         ICInstance inst;
  32.     } start_component_params;
  33.     
  34.     *inst = nil;
  35.     if (Gestalt(gestaltComponentMgr, &response) == noErr) {
  36.         *inst = (ICInstance) OpenDefaultComponent(internetConfigurationComponentType, internetConfigurationComponentSubType);
  37.     };
  38.     if (*inst == nil) {
  39.         err = badComponentInstance;
  40.     } else {
  41.         start_component_params.flags = 0;
  42.         start_component_params.size = 4;
  43.         start_component_params.what = 0;
  44.         start_component_params.creator = creator;
  45.         start_component_params.inst = *inst;
  46.         err = CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &start_component_params);
  47.         if (err != noErr) {
  48.             junk = CloseComponent((ComponentInstance) *inst);
  49.             *inst = nil;
  50.         };
  51.     };
  52.     return(err);
  53. }
  54.  
  55. pascal ICError ICStop(ICInstance inst)
  56. {
  57.     ICError err;
  58.     ICError err2;
  59.     struct {
  60.         char flags;
  61.         char size;
  62.         short what;
  63.         //
  64.         //
  65.         ICInstance inst;
  66.     } stop_component_params;
  67.     
  68.     stop_component_params.flags = 0;
  69.     stop_component_params.size = 0;
  70.     stop_component_params.what = 1;
  71.     stop_component_params.inst = inst;
  72.     err = CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &stop_component_params);
  73.     err2 = CloseComponent((ComponentInstance) inst);
  74.     if (err == noErr) {
  75.         err = err2;
  76.     };
  77.     return(err);
  78. }
  79.  
  80. pascal ICError ICFindConfigFile(ICInstance inst, short count, ICDirSpecArrayPtr folders)
  81. {
  82.     struct {
  83.         char flags;
  84.         char size;
  85.         short what;
  86.         //
  87.         ICDirSpecArrayPtr folders;
  88.         short count;
  89.         //
  90.         ICInstance inst;
  91.     } find_config_file_params;
  92.     
  93.     find_config_file_params.flags = 0;
  94.     find_config_file_params.size = 6;
  95.     find_config_file_params.what = 2;
  96.     find_config_file_params.folders = folders;
  97.     find_config_file_params.count = count;
  98.     find_config_file_params.inst = inst;
  99.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &find_config_file_params));
  100. }
  101.  
  102. pascal ICError ICSpecifyConfigFile(ICInstance inst, FSSpec *config)
  103. {
  104.     struct {
  105.         char flags;
  106.         char size;
  107.         short what;
  108.         //
  109.         FSSpec *config;
  110.         //
  111.         ICInstance inst;
  112.     } specify_config_file_params;
  113.     
  114.     specify_config_file_params.flags = 0;
  115.     specify_config_file_params.size = 4;
  116.     specify_config_file_params.what = 3;
  117.     specify_config_file_params.config = config;
  118.     specify_config_file_params.inst = inst;
  119.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &specify_config_file_params));
  120. }
  121.  
  122. pascal ICError ICGetSeed(ICInstance inst, long *seed)
  123. {
  124.     struct {
  125.         char flags;
  126.         char size;
  127.         short what;
  128.         //
  129.         long *seed;
  130.         //
  131.         ICInstance inst;
  132.     } get_seed_params;
  133.     
  134.     get_seed_params.flags = 0;
  135.     get_seed_params.size = 4;
  136.     get_seed_params.what = 4;
  137.     get_seed_params.seed = seed;
  138.     get_seed_params.inst = inst;
  139.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &get_seed_params));
  140. }
  141.  
  142. pascal ICError ICBegin(ICInstance inst, ICPerm perm)
  143. {
  144.     struct {
  145.         char flags;
  146.         char size;
  147.         short what;
  148.         //
  149.         ICPerm perm;
  150.         //
  151.         ICInstance inst;
  152.     } begin_params;
  153.     
  154.     begin_params.flags = 0;
  155.     begin_params.size = 2;
  156.     begin_params.what = 5;
  157.     begin_params.perm = perm;
  158.     begin_params.inst = inst;
  159.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &begin_params));
  160. }
  161.  
  162. pascal ICError ICGetPref(ICInstance inst, ConstStr255Param key, ICAttr *attr, Ptr buf, long *size)
  163. {
  164.     struct {
  165.         char flags;
  166.         char size;
  167.         short what;
  168.         //
  169.         long *psize;
  170.         Ptr buf;
  171.         ICAttr *attr;
  172.         Str255 *key;
  173.         //
  174.         ICInstance inst;
  175.     } get_pref_params;
  176.     
  177.     get_pref_params.flags = 0;
  178.     get_pref_params.size = 16;
  179.     get_pref_params.what = 6;
  180.     //
  181.     get_pref_params.psize = size;
  182.     get_pref_params.buf = buf;
  183.     get_pref_params.attr = attr;
  184.     get_pref_params.key = (Str255 *) key;
  185.     //
  186.     get_pref_params.inst = inst;
  187.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &get_pref_params));
  188. }
  189.  
  190. pascal ICError ICSetPref(ICInstance inst, ConstStr255Param key, ICAttr attr, Ptr buf, long size)
  191. {
  192.     struct {
  193.         char flags;
  194.         char size;
  195.         short what;
  196.         //
  197.         long psize;
  198.         Ptr buf;
  199.         ICAttr attr;
  200.         Str255 *key;
  201.         //
  202.         ICInstance inst;
  203.     } set_pref_params;
  204.     
  205.     set_pref_params.flags = 0;
  206.     set_pref_params.size = 16;
  207.     set_pref_params.what = 7;
  208.     //
  209.     set_pref_params.psize = size;
  210.     set_pref_params.buf = buf;
  211.     set_pref_params.attr = attr;
  212.     set_pref_params.key = (Str255 *) key;
  213.     //
  214.     set_pref_params.inst = inst;
  215.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &set_pref_params));
  216. }
  217.  
  218. pascal ICError ICCountPref(ICInstance inst, long *count)
  219. {
  220.     struct {
  221.         char flags;
  222.         char size;
  223.         short what;
  224.         //
  225.         long *count;
  226.         //
  227.         ICInstance inst;
  228.     } count_pref_params;
  229.     
  230.     count_pref_params.flags = 0;
  231.     count_pref_params.size = 4;
  232.     count_pref_params.what = 8;
  233.     count_pref_params.count = count;
  234.     count_pref_params.inst = inst;
  235.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &count_pref_params));
  236. }
  237.  
  238. pascal ICError ICGetIndPref(ICInstance inst, long n, Str255 key)
  239. {
  240.     struct {
  241.         char flags;
  242.         char size;
  243.         short what;
  244.         //
  245.         StringPtr key;
  246.         long n;
  247.         //
  248.         ICInstance inst;
  249.     } get_ind_pref_params;
  250.     
  251.     get_ind_pref_params.flags = 0;
  252.     get_ind_pref_params.size = 8;
  253.     get_ind_pref_params.what = 9;
  254.     //
  255.     get_ind_pref_params.key = (StringPtr) key;
  256.     get_ind_pref_params.n = n;
  257.     //
  258.     get_ind_pref_params.inst = inst;
  259.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &get_ind_pref_params));
  260. }
  261.  
  262. pascal ICError ICDeletePref(ICInstance inst, ConstStr255Param key)
  263. {
  264.     struct {
  265.         char flags;
  266.         char size;
  267.         short what;
  268.         //
  269.         Str255 *key;
  270.         //
  271.         ICInstance inst;
  272.     } delete_pref_params;
  273.     
  274.     delete_pref_params.flags = 0;
  275.     delete_pref_params.size = 4;
  276.     delete_pref_params.what = 12;
  277.     //
  278.     delete_pref_params.key = (Str255 *) key;
  279.     //
  280.     delete_pref_params.inst = inst;
  281.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &delete_pref_params));
  282. }
  283.  
  284. pascal ICError ICEnd(ICInstance inst)
  285. {
  286.     struct {
  287.         char flags;
  288.         char size;
  289.         short what;
  290.         //
  291.         //
  292.         ICInstance inst;
  293.     } end_params;
  294.     
  295.     end_params.flags = 0;
  296.     end_params.size = 0;
  297.     end_params.what = 10;
  298.     //
  299.     end_params.inst = inst;
  300.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &end_params));
  301. }
  302.  
  303. pascal ICError ICDefaultFileName(ICInstance inst, Str63 name)
  304. {
  305.     struct {
  306.         char flags;
  307.         char size;
  308.         short what;
  309.         //
  310.         StringPtr name;
  311.         //
  312.         ICInstance inst;
  313.     } default_file_name_params;
  314.     
  315.     default_file_name_params.flags = 0;
  316.     default_file_name_params.size = 4;
  317.     default_file_name_params.what = 11;
  318.     default_file_name_params.name = (StringPtr) name;
  319.     default_file_name_params.inst = inst;
  320.     return(CallUniversalProc(CallComponentUPP, uppCallComponentProcInfo, &default_file_name_params));
  321. }
  322.  
  323. pascal ICError ICGetComponentInstance(ICInstance inst, Ptr *component_inst)
  324. {
  325.     *component_inst = inst;
  326.     
  327.     return 0;
  328. }
  329.